package com.lanou.controller;

import com.lanou.entity.Phone;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;

/**
 * @author 姚云鹏
 * Create at: 2018/6/8 14:59
 */
@Controller
@RequestMapping("/phone")
public class PhoneController {

    @RequestMapping("/add")
    public void add(@Valid Phone phone, BindingResult br){
        if(br.hasErrors()){
            System.out.println("没有通过校验");
//            FieldError brandError = br.getFieldError("brand");
//
//            System.out.println(brandError.getDefaultMessage());
        }else{
            System.out.println("通过了校验");
        }
    }

}
